package common.store.admin.contoller;



import common.store.admin.dto.Category;
import common.store.admin.dto.Product;
import common.store.admin.service.AdminProductService;
import common.store.admin.service.CategoryService;
import common.store.admin.service.impl.AdminProductServiceImpl;
import common.store.admin.service.impl.CategoryServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/adminProductDel")
public class AdminProductDelServlet extends HttpServlet {

    AdminProductService adminProductService;

    CategoryService categoryService;
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String pid = req.getParameter("pid");
        adminProductService = new AdminProductServiceImpl();

        Integer rows = adminProductService.DelProductByPid(pid);

        if(rows > 0){
            resp.sendRedirect(req.getContextPath() + "/adminProductList");//刷新页面过程
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req , resp);
    }
}
